#include <iostream>
typedef long long ll;
using namespace std;
ll N;
ll C(int a, int b)//求第i行第j列的值
{
	ll res = 1;
	for (ll i = a, j = 1; j <= b; i--, j++)
	{
		res = res * i / j;
		if (res > N)//如果中间结果超过N就直接返回
			return res;
	}
	return res;
}
int main()
{
	N=2022;
	for (int k = 16; k >= 0; k--)//一列一列的找
	{
		ll l = 2 * k, r = max(N, l), mid;
		while (l <= r) {//对第k列二分查找行
			mid = l + (r - l) / 2;//二分行
			ll CC = C(mid, k);
			if (CC == N)
				break;
			else if (CC > N)
				r = mid - 1;
			else
				l = mid + 1;
		}
		if (C(mid, k) == N)
		{//第mid行、第k列的数就是N
			cout << (mid + 1) * mid / 2 + k + 1 << endl;
			//杨辉三角形的行数符号公差为1的等差数列，故用等差数列求和公式
			//加上第几列再加上1（因为列从0开始）即可得出该数的位置
			break;
		}
	}
	return 0;
}